<?

/**
 * $Id: Admin.mod.php 703 2008-06-26 11:15:09Z pawy $
 * Klasa przechowujaca dane zalogowanego admina
 *
 */
class Admin {
	const SMARTY_NAME = 'admin';
	const SMARTY_DEFAULT_ACCESS = 'admin';
	/**
	 * id admnina
	 *
	 * @var integer
	 */
	private $userId;
	/**
	 * email admina
	 *
	 * @var string
	 */
	private $email;
	/**
	 * Imie i nazwisko admina
	 *
	 * @var string
	 */
	private $userName;
	/**
	 * login admina
	 *
	 * @var string
	 */
	private $login;
	/**
	 * Rola admina
	 *
	 * @var string
	 */
	private $role;
	/**
	 * Szablon uprawnien
	 *
	 * @var array
	 */
	private $access;
	/**
	 * Data i godzina ostatniego logowania
	 *
	 * @var string
	 */
	private $lastLogin;

	static $tableName = 'mf_admin';
	static $classTablePK = 'id_mf_admin';

	static $className = __CLASS__;


	static $fields = array(
		'id_mf_admin'			=> 'id',
		'email'				=> 'email',
		'first_name'			=> 'firstName',
		'last_name'			=> 'lastName',
		'login'				=> 'login',
		'password'			=> 'password',
		'role'				=> 'role',
		'last_login'			=> 'lastLogin',
		'description'			=> 'description',
		'online'			=> 'online',
		'last_activity'			=> 'lastActivity',
		'phone'				=> 'phone',
		'authorized'			=> 'authorized',
		'photo_src'			=> 'photoSrc',
		'forum_count'		=> 'forumCount',
		'customer_count'	=> 'customerCount',
		'_create_time'		=> 'createTime',
		'moderated_post_count'		=> 'moderatedPostCount',
		'archive'			=> 'archive',
		'delete_time'		=> 'deleteTime'
	);

	public function getLogin() {
		return $this->userName;
	}

	public  function GetTableName(){
		return self::$tableName;
      }

	public  function GetFields(){
		return self::$fields;
      }

	public  function GetClassName(){
		return self::$className;
      }


    public function GetClassTablePK() {
        return self::$classTablePK;
    }

	/**
	 * Konstruktor klasy
	 *
	 * @param integer $userId
	 * @param string $email
	 * @param string $userName
	 * @param string $login
	 * @param string $role
	 * @param array $access
	 * @param string $lastLogin
	 */
	public function __construct($userId, $email, $userName, $login, $role, $access, $lastLogin) {

		$this->userId = $userId;
		$this->email = $email;
		$this->userName = $userName;
		$this->login = $login;
		$this->role = $role;
		$this->access = $access;
		$this->lastLogin = $lastLogin;

	}

	/**
	 * Funkcja kontrolna
	 *
	 * @return boolean
	 */
	public function getAuthorized() {
		return true;
	}

	/**
	 * Zwraca imie i nazwisko
	 *
	 * @return string
	 */
	public function GetName() {
		return $this->userName;
	}

	/**
	 * Zwraca date ostatniego logowania
	 *
	 * @return string
	 */
	public function GetLastLogin() {
		return $this->lastLogin;
	}

	/**
	 * Zwraca role
	 *
	 * @return string
	 */
	public function GetRole() {
		return $this->role;
	}


	/**
	 * Zwraca id admina
	 *
	 * @return integer
	 */
	public function GetId() {
		return $this->userId;
	}

	/**
	 * Sprawdza uprawnienia do zasobu
	 *
	 * @param string $where
	 * @return boolean
	 */
	public function CheckAccess($where) {
		
	
		if (array_key_exists($where, $this->access)) {
			return true;
		} else {
			return false;
		}
		

	}
	
	public function GetEmail() {
		return $this->email;
	}
}
?>